home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / TranslationExtensions.p < prev    next >
Text File  |  1996-05-01  |  7KB  |  189 lines

  1. {
  2.      File:        TranslationExtensions.p
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT TranslationExtensions;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  28. {$SETC __TRANSLATIONEXTENSIONS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC TranslationExtensionsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MEMORY__}
  35. {$I Memory.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __FILES__}
  38. {$I Files.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __QUICKDRAW__}
  41. {$I Quickdraw.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __COMPONENTS__}
  44. {$I Components.p}
  45. {$ENDC}
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51.  
  52. CONST
  53.     kSupportsFileTranslation    = 1;
  54.     kSupportsScrapTranslation    = 2;
  55.     kTranslatorCanGenerateFilename = 4;
  56.  
  57. {  better names for 4-char codes }
  58.  
  59. TYPE
  60.     FileType                            = OSType;
  61.     ScrapType                            = ResType;
  62.     TranslationAttributes                = LONGINT;
  63.  
  64. CONST
  65.     taDstDocNeedsResourceFork    = 1;
  66.     taDstIsAppTranslation        = 2;
  67.  
  68.  
  69. TYPE
  70.     FileTypeSpecPtr = ^FileTypeSpec;
  71.     FileTypeSpec = RECORD
  72.         format:                    FileType;
  73.         hint:                    LONGINT;
  74.         flags:                    TranslationAttributes;                    {  taDstDocNeedsResourceFork, taDstIsAppTranslation }
  75.         catInfoType:            OSType;
  76.         catInfoCreator:            OSType;
  77.     END;
  78.  
  79.     FileTranslationListPtr = ^FileTranslationList;
  80.     FileTranslationList = RECORD
  81.         modDate:                LONGINT;
  82.         groupCount:                LONGINT;
  83.                                                                         {      unsigned long    group1SrcCount; }
  84.                                                                         {      unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec); }
  85.                                                                         {   FileTypeSpec    group1SrcTypes[group1SrcCount] }
  86.                                                                         {   unsigned long    group1DstCount; }
  87.                                                                         {   unsigned long    group1DstEntrySize = sizeof(FileTypeSpec); }
  88.                                                                         {   FileTypeSpec    group1DstTypes[group1DstCount] }
  89.     END;
  90.  
  91.     FileTranslationListHandle            = ^FileTranslationListPtr;
  92.     ScrapTypeSpecPtr = ^ScrapTypeSpec;
  93.     ScrapTypeSpec = RECORD
  94.         format:                    ScrapType;
  95.         hint:                    LONGINT;
  96.     END;
  97.  
  98.     ScrapTranslationListPtr = ^ScrapTranslationList;
  99.     ScrapTranslationList = RECORD
  100.         modDate:                LONGINT;
  101.         groupCount:                LONGINT;
  102.                                                                         {      unsigned long        group1SrcCount; }
  103.                                                                         {      unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec); }
  104.                                                                         {   ScrapTypeSpec        group1SrcTypes[group1SrcCount] }
  105.                                                                         {   unsigned long        group1DstCount; }
  106.                                                                         {      unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec); }
  107.                                                                         {   ScrapTypeSpec        group1DstTypes[group1DstCount] }
  108.     END;
  109.  
  110.     ScrapTranslationListHandle            = ^ScrapTranslationListPtr;
  111. {  definition of callbacks to update progress dialog }
  112.     TranslationRefNum                    = LONGINT;
  113. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  114. {
  115. ****************************************************************************************
  116. *
  117. * This routine sets the advertisement in the top half of the progress dialog.
  118. * It is called once at the beginning of your DoTranslateFile routine.
  119. *
  120. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  121. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  122. *                            Before returning from DoTranslateFile, you should dispose
  123. *                            of the memory.  (Normally, it is in the temp translation heap
  124. *                            so it is cleaned up for you.)
  125. *
  126. * Exit:    returns            noErr, paramErr, or memFullErr
  127. }
  128. FUNCTION SetTranslationAdvertisement(refNum: TranslationRefNum; advertisement: PicHandle): OSErr;
  129.     {$IFC NOT GENERATINGCFM}
  130.     INLINE $7002, $ABFC;
  131.     {$ENDC}
  132. {
  133. ****************************************************************************************
  134. *
  135. * This routine updates the progress bar in the progress dialog.
  136. * It is called repeatedly from within your DoTranslateFile routine.
  137. * It should be called often, so that the user will get feedback if he tries to cancel.
  138. *
  139. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  140. *            progress    percent complete (0-100)
  141. *
  142. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  143. *            returns        noErr, paramErr, or memFullErr
  144. }
  145. FUNCTION UpdateTranslationProgress(refNum: TranslationRefNum; percentDone: INTEGER; VAR canceled: BOOLEAN): OSErr;
  146.     {$IFC NOT GENERATINGCFM}
  147.     INLINE $7001, $ABFC;
  148.     {$ENDC}
  149. {  ComponentMgr selectors for routines }
  150.  
  151. CONST
  152.     kTranslateGetFileTranslationList = 0;                        {  component selectors }
  153.     kTranslateIdentifyFile        = 1;
  154.     kTranslateTranslateFile        = 2;
  155.     kTranslateGetTranslatedFilename = 3;
  156.     kTranslateGetScrapTranslationList = 10;                        {  skip to scrap routines }
  157.     kTranslateIdentifyScrap        = 11;
  158.     kTranslateTranslateScrap    = 12;
  159.  
  160. {  Routines to implment in a file translation extension }
  161.  
  162. TYPE
  163.     DoGetFileTranslationListProcPtr = ProcPtr;  { FUNCTION DoGetFileTranslationList(self: ComponentInstance; translationList: FileTranslationListHandle): ComponentResult; }
  164.  
  165.     DoIdentifyFileProcPtr = ProcPtr;  { FUNCTION DoIdentifyFile(self: ComponentInstance; (CONST)VAR theDocument: FSSpec; VAR docType: FileType): ComponentResult; }
  166.  
  167.     DoTranslateFileProcPtr = ProcPtr;  { FUNCTION DoTranslateFile(self: ComponentInstance; refNum: TranslationRefNum; (CONST)VAR sourceDocument: FSSpec; srcType: FileType; srcTypeHint: LONGINT; (CONST)VAR dstDoc: FSSpec; dstType: FileType; dstTypeHint: LONGINT): ComponentResult; }
  168.  
  169.     DoGetTranslatedFilenameProcPtr = ProcPtr;  { FUNCTION DoGetTranslatedFilename(self: ComponentInstance; dstType: FileType; dstTypeHint: LONGINT; VAR theDocument: FSSpec): ComponentResult; }
  170.  
  171. {  Routine to implement in a scrap translation extension }
  172.     DoGetScrapTranslationListProcPtr = ProcPtr;  { FUNCTION DoGetScrapTranslationList(self: ComponentInstance; list: ScrapTranslationListHandle): ComponentResult; }
  173.  
  174.     DoIdentifyScrapProcPtr = ProcPtr;  { FUNCTION DoIdentifyScrap(self: ComponentInstance; dataPtr: UNIV Ptr; dataLength: Size; VAR dataFormat: ScrapType): ComponentResult; }
  175.  
  176.     DoTranslateScrapProcPtr = ProcPtr;  { FUNCTION DoTranslateScrap(self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: UNIV Ptr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: LONGINT; dstData: Handle; dstType: ScrapType; dstTypeHint: LONGINT): ComponentResult; }
  177.  
  178. {$ENDC}
  179. {$ALIGN RESET}
  180. {$POP}
  181.  
  182. {$SETC UsingIncludes := TranslationExtensionsIncludes}
  183.  
  184. {$ENDC} {__TRANSLATIONEXTENSIONS__}
  185.  
  186. {$IFC NOT UsingIncludes}
  187.  END.
  188. {$ENDC}
  189.